package com.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * Created by xiao zeng on 2017/6/30.
 */
@Controller
@RequestMapping("/admin")
public class Auto {


    @RequestMapping("/login")
    public String login(){
        return "/WEB-INF/admin/login";
    }

    @RequestMapping("/show")
    public String show(){
        return "/WEB-INF/admin/show";
    }


    @RequestMapping("/submit") @ResponseBody
    public void submit(HttpServletRequest req, HttpServletResponse resp) throws IOException {
        HttpSession ss = req.getSession();
        ss.setAttribute("admin","haha");
        resp.setContentType("text/html;charset=utf-8");
        PrintWriter out = resp.getWriter();
        out.print("登陆成功");
    }


    @RequestMapping("/outsubmit") @ResponseBody
    public void outsubmit(HttpServletRequest req){
        HttpSession ss = req.getSession();
        ss.removeAttribute("admin");
    }

}
